<extend name="./Base/base" />

<block name="main">
<div class="row">
	<div class="col-md-6">
		<div class="panel">
			<div class="panel-heading bk-bg-primary">
				<h6><i class="fa fa-indent red"></i>分类修改</h6>							
			</div>
			<div class="panel-body">
				<form action="" method="post" enctype="multipart/form-data" class="form-horizontal ">
				<input type="hidden" name="id" value="{$model['id']}">
					<!-- <div class="form-group">
						<label class="col-md-3 control-label">Static</label>
						<div class="col-md-9">
							<p class="form-control-static">Username</p>
						</div>
					</div> -->
					<div class="form-group">
						<label class="col-md-3 control-label" for="email-input">分类名称</label>
						<div class="col-md-9">
							<input id="email-input" name="name" class="form-control" value="{$model['name']}">
							<!-- <span class="help-block">填写分类</span> -->
						</div>
					</div>
					
					<div class="form-group">
						<label class="col-md-3 control-label" for="disabled-input">选择分类</label>
						<div class="col-md-9">
							<select  name="select" class="form-control" size="1" disabled="">
							<option value="0">请选择</option>
							<foreach name="list" item="vo">								
								<option  value="{$vo.id}" <if condition="$vo['id'] eq  $model['pid'] ">selected="selected"</if> >{$vo.name}</option>
							</foreach>
							</select>
						</div>
					</div>
					<div class="form-group">
						<label class="col-md-3 control-label" for="select">分类描述</label>&nbsp&nbsp&nbsp 	
						<textarea  id="EssayUser_content" name="content" placeholder="请输入分类描述...." style="width:490px;height:150px;border:solid 1px #FAEBD7; border-radius:10px;resize:none;">{$model['count']}</textarea>
					</div>
					<div id="message" style="margin-left:255px;"></div>
					<br>
					<button  onclick="button_cate();return false;" class="btn btn-large btn-primary" style="margin-left:35%;">&nbsp&nbsp&nbsp&nbsp&nbsp提交&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</button>
				</form>
			</div>	
		</div>	
	</div>
</div>
</block>
<block name="script_user">
	<script type="text/javascript">
		function button_cate(){
		var	name = $("input[name='name']").val();
		var select = $("select[name='select']").val();
		var id = $("input[name='id']").val();
		var content = $("textarea[ name='content']").val();
		if ($("input[name='name']").val() == '') {
			$("#message").html('<p style="color:red">ERROR: 分类名称不可为空</p>');
			return false;
		};
		$.post("{:U('Category/category_update')}",{name:name,pid:select,id:id,count:content},function(data){
			if (data == 1) {
				$("#message").html('<p style="color:red">ERROR: 服务器异常,请检查</p>');
			}else if (data == 3) {
				$("#message").html('<p style="color:red">ERROR: 分类名已经存在,或没改分类名</p>');
			}else {
				var res = data.substr(0,1);
				var url = data.substring(2);
				if (res == 2) {
					window.location.href = url;
				};
			};
			
		});
    		
	}
	</script>
</block>